val rdd = sc.parallelize(List(("toto","38"),("titi","18"),("tata","30")))

val dataframe = rdd.toDF("nom","age")
dataframe.show

dataframe.createOrReplaceTempView("test")

val dataframesql = spark.sql("select * from test")

-------------------------------------------------------------------------------------
spark-shell --driver-class-path /opt/spark/jars/postgresql-42.2.2.jar --jars /opt/spark/jars/postgresql-42.2.2.jar

val jdbcDF = spark.read.format("jdbc").
option("url","jdbc:postgresql://127.0.0.1/postgres").
option("dbtable","public.personnes").
option("user","postgres").
option("password","aimad123").
load()

jdbcDF.printSchema()
jdbcDF.columns
jdbcDF.dtypes
jdbcDF.show()
jdbcDF.drop("cp")
jdbcDF.filter("cp <> 31000").show
jdbcDF.filter("!cp <> 31000").show
jdbcDF.select("age","cp").distinct().show
